<script setup>
import topNav from "../../components/topNav.vue";
import { onMounted, reactive, ref, nextTick } from "vue";
import { onLoad, onShow, onReachBottom, onBackPress } from "@dcloudio/uni-app";
import { appProductQuery, salePriceCreate } from "@/services/goods";
import pomiss from "@/components/pomiss/index.vue";
import {
  getPlan,
  appPlanProduct,
  approveDirect,
  getPlanDetail,
} from "@/services/stocktaking";

// import tabbarView from "../components/tabbar.vue";
const scrollTop = ref(0);
const code = ref("");
const id = ref("");
const showNO = ref(false);
const showNOIs = ref(false);
const showP = ref(false);
const pagesUp = ref(false);
const pagesword = ref(false);
onBackPress(() => {
  if (newTakeList.value.length > 0) {
    if (pagesword.value) {
      return false;
    }

    pagesUp.value = true;
    uni.showModal({
      title: "提示",
      content: "您已有盘点数据，是否确认退出？",
      success: function (res) {
        if (res.confirm) {
          console.log("用户点击确定");
          pagesword.value = true;
          pagesUp.value = false;
          uni.navigateBack();
        } else if (res.cancel) {
          pagesUp.value = true;
          console.log("用户点击取消");
        }
      },
    });
  } else {
    pagesUp.value = false;
  }
  return pagesUp.value;
});

onLoad((option) => {
  id.value = option.id;

  code.value = option.code ? option.code : "";
  form.value.keyword = option.code ? option.code : "";

  // code.value = "2094323298709";
  // getAppPlanProduct();
  // if (uni.getStorageSync("selectShopType")) {
  //   uni.removeStorageSync("selectShopType");
  // }
  getPlanGoods();
});

onShow(() => {
  // if (uni.getStorageSync("selectShopType")) {
  //   showSelect.value = uni.getStorageSync("selectShopType");
  // }
  if (uni.getStorageSync("barCodeP")) {
    code.value = uni.getStorageSync("barCodeP")
      ? uni.getStorageSync("barCodeP")
      : "";
    // form.value.keyword = uni.getStorageSync("barCodeP")
    //   ? uni.getStorageSync("barCodeP")
    //   : "";
    getAppPlanProduct();
  }
});
const saveFun = () => {
  // console.log("取消");
  // form.value.name = "";
  // loading.value = "";
  // getAppProductQuery(1);
};

const searchFun = (val) => {
  console.log("取2消", val);
  form.value.keyword = val;

  loading.value = "";
  console.log(form.value.name);
  // getAppProductQuery(1);
  if (val) {
    getPlanGoodsSearch();
  } else {
  }
};

onReachBottom(() => {
  console.log("触底了");
  // getAppProductQuery();
});
onMounted(() => {
  // getAppProductQuery();
});

//获取商品
const form = ref({
  categoryId: "",
  pageIndex: 1,
  pageSize: 20,
  barCode: "",
  code: "",
  name: "",
  skuCode: "",
  categoryId: "",
  available: "",
  keyword: "",
});

const productData = ref([]);
const productDataSearch = ref([]);
const newTakeList = ref([]);

const loading = ref("");
const getPlanGoodsSearch = async () => {
  productDataSearch.value = [];
  uni.showLoading({
    title: "加载中",
    mask: true,
  });
  try {
    let res = await getPlanDetail({
      id: id.value,
      keyword: form.value.keyword,
    });
    if (res.code == 200) {
      res.data.forEach((item) => {
        newTakeList.value.forEach((item2) => {
          if (item.productId == item2.productId) {
            item.newTakeNum = item2.takeNum;
          }
        });
      });

      productDataSearch.value = productDataSearch.value.concat(res.data);
      uni.hideLoading();
      // if (code.value) {
      //   getAppPlanProduct();
      // } else {
      //   if (uni.getStorageSync("goods_p")) {
      //     uni.removeStorageSync("goods_p");
      //   }
      // }
    } else {
      uni.hideLoading();
      uni.showToast({
        title: res.message,
        icon: "none",
      });
    }
  } catch (e) {
    uni.hideLoading();
    uni.showToast({
      title: e.message,
      icon: "none",
    });
  }
};
const getPlanGoods = async () => {
  uni.showLoading({
    title: "加载中",
    mask: true,
  });
  try {
    let res = await getPlan({ id: id.value });
    if (res.code == 200) {
      productData.value = productData.value.concat(res.data.details);
      uni.hideLoading();
      if (code.value) {
        getAppPlanProduct();
      } else {
        if (uni.getStorageSync("goods_p")) {
          uni.removeStorageSync("goods_p");
        }
      }
    } else {
      uni.hideLoading();
      uni.showToast({
        title: res.message,
        icon: "none",
      });
    }
  } catch (e) {
    uni.hideLoading();
    uni.showToast({
      title: e.message,
      icon: "none",
    });
  }
};

const getAppPlanProduct = async () => {
  if (uni.getStorageSync("goods_p")) {
    newTakeList.value = JSON.parse(uni.getStorageSync("goods_p"));
    newTakeList.value.forEach((item, index) => {
      productData.value.forEach((item2, index2) => {
        if (item.productId == item2.productId) {
          item2.newTakeNum = item.takeNum;
        }
      });
    });
  }
  try {
    let res = await appPlanProduct({ id: id.value, barCode: code.value });
    if (res.code == 200) {
      if (res.data.isCheck) {
        productData.value.forEach((item, index) => {
          // console.log("item", item, item.id == res.data.id);

          if (item.productId == res.data.id) {
            // console.log("item", item, item.id == res.data.id);
            itemObj.value = item;
            selectitem.value = index;
            priceValue.value = String(
              item.takeNum
                ? item.takeNum
                : item.stockNum > 0
                ? item.stockNum
                : 0
            );
            selectNumIndex.value = -1;
            keyWord.value.open();
          }
        });
      } else {
        itemObj.value = res.data;
        if (uni.getStorageSync("barCodeP")) {
          uni.removeStorageSync("barCodeP");
        }
      }
    } else {
      showNO.value = false;
      if (uni.getStorageSync("barCodeP")) {
        uni.removeStorageSync("barCodeP");
      }
      uni.showToast({
        title: res.message,
        icon: "none",
      });
    }
  } catch (e) {
    showNO.value = false;
    uni.showToast({
      title: e.message,
      icon: "none",
    });
  }
};
const getAppProductQuery = async (index) => {
  if (index == 1) {
    productData.value = [];
  }
  if (index) {
    form.value.pageIndex = index;
  }
  if (loading.value == "noMore") {
    return;
  }
  loading.value = "Loading";
  try {
    let res = await appProductQuery(form.value);
    if (res.code == 200) {
      productData.value = productData.value.concat(res.data.datas);
      console.log(productData.value);
      form.value.pageIndex = form.value.pageIndex + 1;

      if (res.data.datas.length < form.value.pageSize) {
        loading.value = "noMore";
      } else {
        loading.value = "More";
      }
    } else {
    }

    console.log(res);
  } catch (e) {}
};

//改价模块
const showSelect = ref("");
const itemObj = ref({});
const selectitem = ref(0);
const num = ref(0);
const show = ref(false);
const showKeyboard = ref(true);
const priceValue = ref("30.10");
const keyboard = ref(null);
const keyboardHeight = ref(0);
const isSr = ref(false);
const themeVars = ref({
  numberKeyboardBackground: "#F7F8FA ",
  numberKeyboardKeyBackground: "#FFFFFF",
  numberKeyboardButtonBackground: "#FF5722",
});

const onClickItem = (item, index) => {
  itemObj.value = item;
  selectitem.value = index;
  priceValue.value = String(
    item.takeNum ? item.takeNum : item.stockNum > 0 ? item.stockNum : 0
  );
  selectNumIndex.value = -1;
  keyWord.value.open();
  // show.value = true;
  // showKeyboard.value = true;
  // nextTick(() => {
  //   setTimeout(() => {
  //     keyboardHeight.value = keyboard.value.$el.offsetHeight;
  //     console.log(keyboard.value.$el.offsetHeight, keyboard.value);
  //   }, 100);
  // });
};

const onInput = (item) => {
  setTimeout(() => {
    priceValue.value = handlePriceInput(priceValue.value);
  }, 100);

  console.log(item);
};
const handlePriceInput = (event) => {
  let value = event;

  // 过滤掉非数字和小数点的字符
  value = value.replace(/[^0-9.]/g, "");

  // 确保只有一个小数点
  const parts = value.split(".");
  if (parts.length > 2) {
    value = parts[0] + "." + parts.slice(1).join("");
  }

  // 如果以小数点开头，添加 '0'
  if (value.startsWith(".")) {
    value = "0" + value;
  }

  // 如果小数点后超过两位，截断
  const decimalParts = value.split(".");
  if (decimalParts.length === 2 && decimalParts[1].length > 2) {
    value = decimalParts[0] + "." + decimalParts[1].slice(0, 2);
  }
  console.log("value", value);
  // form.value.price = value;
  return value;
};
//提交改价

const onBlue = async () => {
  try {
    let res = await salePriceCreate({
      productId: itemObj.value.id,
      revisePrice: priceValue.value,
      description: "手机端操作",
    });
    if (res.code == 200) {
      showToast("修改成功");
      num.value = num.value + 1;
      productData.value[selectitem.value].newsalePrice = priceValue.value;

      // productData.value[selectitem.value].salePrice=priceValue.value

      // getAppProductQuery(1);
      show.value = false;
    } else {
      showToast(res.msg);
    }
  } catch (e) {
    showToast(e.msg);
  }
};

const isTJ = ref(false);
const goRecord = async () => {
  if (isTJ.value) {
    return;
  }
  isTJ.value = true;

  try {
    let res = await approveDirect({
      planId: id.value,
      products: newTakeList.value,
    });
    if (res.code == 200) {
      show.value = false;
      uni.showToast({
        title: "提交成功",
        icon: "none",
      });
      isTJ.value = false;

      uni.redirectTo({
        url: "/pages/stocktaking/home/index",
      });
    } else {
      isTJ.value = false;
      uni.showToast({
        title: res.msg,
        icon: "none",
      });
    }
  } catch (e) {
    isTJ.value = false;
    uni.showToast({
      title: e.message,
      icon: "none",
    });
  }

  // uni.navigateTo({
  //   url: "/pages/goods/goods_price_record/index",
  // });
};

const keyWord = ref(null);
const selectNumIndex = ref(-1);
const del = (e) => {
  if (e == 0) {
    selectNumIndex.value = selectNumIndex.value - 1;
  } else if (e == 1) {
    selectNumIndex.value = selectNumIndex.value + 1;
  }
};
const keyWordItem = (index) => {
  selectNumIndex.value = index;
};
//金额键盘
const inp = (e) => {};

const hide = () => {
  if (uni.getStorageSync("barCodeP")) {
    uni.removeStorageSync("barCodeP");
  }
  if (num.value > 0) {
    // numblur();
  } else {
    // jsnum.value = 0;
  }
  // isinputto.value = false;
  // isshowput.value = true;
};
const confirm = async () => {
  // console.log("确认", itemObj.value);
  // console.log("确认", form.value.keyword);
  if (form.value.keyword) {
    productDataSearch.value[selectitem.value].takeNum = priceValue.value;
    productData.value.forEach((item) => {
      if (item.productId == itemObj.value.productId) {
        item.takeNum = priceValue.value;
      }
    });
  } else {
    productData.value[selectitem.value].takeNum = priceValue.value;
  }

  let isin = false;
  if (newTakeList.value.length > 0) {
    newTakeList.value.forEach((item) => {
      if (item.productId == itemObj.value.productId) {
        isin = true;
        item.takeNum = priceValue.value;
      }
      //  else {
      //   newTakeList.value.push({
      //     productId: itemObj.value.productId,
      //     takeNum: priceValue.value,
      //     productName: itemObj.value.productName,
      //     stockNum: itemObj.value.stockNum,
      //   });
      // }
    });
  } else {
    console.log(4);
    isin = true;
    newTakeList.value.push({
      barCode: itemObj.value.barCode || "",
      image: itemObj.value.image,
      productId: itemObj.value.productId,
      takeNum: priceValue.value,
      newtakeNum: priceValue.value,
      productName: itemObj.value.productName,
      stockNum: itemObj.value.stockNum,
    });
  }
  if (!isin) {
    newTakeList.value.push({
      barCode: itemObj.value.barCode || "",
      image: itemObj.value.image,
      productId: itemObj.value.productId,
      takeNum: priceValue.value,
      newtakeNum: priceValue.value,
      productName: itemObj.value.productName,
      stockNum: itemObj.value.stockNum,
    });
  }

  console.log(newTakeList.value);
  uni.setStorageSync("goods_p", JSON.stringify(newTakeList.value));
  if (uni.getStorageSync("barCodeP")) {
    showP.value = true;
    uni.removeStorageSync("barCodeP");
  }
};
const numblur = () => {
  // getcomputeBrokerage(Number(num.value));
};
const closePay = () => {
  keyWord.value.close();
};

const pomissview = ref(null);
const isshowcamera = ref(false);
const codeShow = () => {
  isshowcamera.value = false;
  uni.scanCode({
    scanType: ["barCode", "qrCode"],
    autoDecodeCharset: true,
    autoZoom: true,
    success: async function (res) {
      console.log("条码类型：" + res.scanType);
      console.log("条码内容：" + res.result);
      // form.value.keyword = res.result;
      code.value = res.result;
      try {
        let res = await appPlanProduct({ id: id.value, barCode: code.value });
        if (res.code == 200) {
          if (res.data.isCheck) {
            productData.value.forEach((item, index) => {
              // console.log("item", item, item.id == res.data.id);

              if (item.productId == res.data.id) {
                // console.log("item", item, item.id == res.data.id);
                itemObj.value = item;
                selectitem.value = index;
                priceValue.value = String(
                  item.takeNum
                    ? item.takeNum
                    : item.stockNum > 0
                    ? item.stockNum
                    : 0
                );
                selectNumIndex.value = -1;
                keyWord.value.open();
              }
            });
          } else {
            itemObj.value = res.data;
          }
        } else {
          showNO.value = false;
          uni.showToast({
            title: res.message,
            icon: "none",
          });
        }
      } catch (e) {
        showNO.value = false;
        uni.showToast({
          title: e.message,
          icon: "none",
        });
      }

      // uni.navigateTo({
      //   url: "/pages/goods/goods_price_search/index?code=" + res.result,
      // });
    },
  });
};
const cancelFun = () => {
  isshowcamera.value = false;
};
const scanFun = () => {
  // #ifdef H5
  uni.navigateTo({ url: "/pages/code_sand/index?type=numPd&id=" + id.value });
  // #endif
  // 允许从相机和相册扫码
  // #ifdef APP-PLUS

  isshowcamera.value = true;

  pomissview.value.getPom(
    "为了给您带来更好的服务，需要获取您的相机权限与读取图片及文件权限，用于更换上传图片、扫一扫等功能，对于您授权的信息我们竭尽全力提供安全保护。",
    codeShow
  );

  // #endif
};

const showPFun = () => {
  if (newTakeList.value.length > 0) {
    showP.value = !showP.value;
  } else {
    uni.showToast({
      title: "请选择盘点商品",
      icon: "none",
    });
  }
};
//无网状态
const connected = () => {
  getPlanGoods();
  getAppPlanProduct();
};

const isShowSock = ref(false);
//是否显示有库存
const showSock = () => {
  isShowSock.value = !isShowSock.value;
};
</script>

<template>
  <topNav
    title="商品搜索"
    @save="saveFun"
    rType="cancel"
    @search="searchFun"
    @scan="scanFun"
    :IsSearch="true"
    :code="code"
  ></topNav>

  <jia-PayKeyboard
    v-permission="['manager:salePrice:create', 'shop:salePrice:create']"
    :confirmStyle="{ backgroundColor: '#1679FB' }"
    class="keyWord-index"
    :overlayClose="true"
    ref="keyWord"
    v-model="priceValue"
    :sclectItem="selectNumIndex"
    :showPoint="false"
    @del="del"
    @input="inp"
    @confirm="confirm"
    @hide="hide"
  >
    <view class="PayKeyboard-k">
      <view class="icon-top">
        <up-icon
          @click="closePay"
          name="close"
          color="#86909C"
          size="20"
        ></up-icon
      ></view>
      <view class="PayKeyboard-k-title">{{ itemObj.productName }}</view>
      <view class="PayKeyboard-k-des">{{ itemObj.barCode }}</view>
      <view class="link-to"></view>
      <view class="PayKeyboard-k-num">
        <view class="PayKeyboard-k-num-title">盘点数量</view>
        <view class="PayKeyboard-k-num-input">
          <up-form labelPosition="left" ref="form1" labelWidth="0">
            <up-form-item
              label=" "
              borderBottom
              ref="item1"
              @click="keyWordItem(-1)"
            >
              <view class="PayKeyboard-k-num-input-text">
                <view
                  class="num-view"
                  v-for="(item, index) in priceValue"
                  :key="index"
                  @click.stop="keyWordItem(index)"
                  ><view class="input_lin" v-if="selectNumIndex == index"></view
                  >{{ item }}</view
                >
                <view class="input_lin" v-if="selectNumIndex == -1"></view>
              </view>
              <template #right>
                <text>{{ itemObj.unit ? itemObj.unit : "" }}</text>
              </template>
            </up-form-item>
          </up-form>
        </view>
      </view>
    </view>
  </jia-PayKeyboard>
  <view class="goods_form">
    <view
      v-if="!form.keyword"
      v-for="(item, index) in productData"
      :key="index"
    >
      <view
        class="scroll-Y-item"
        @click="onClickItem(item, index)"
        v-if="!isShowSock || (isShowSock && item.stockNum > 0)"
      >
        <view class="scroll-item-left">
          <image :src="item.image" mode="scaleToFill" />
        </view>
        <view class="scroll-item-right">
          <view class="goods-item-title">
            {{ item.productName }}
          </view>
          <view class="goods-item-spec">
            条形码: {{ item.barCode ? item.barCode : "--" }}
          </view>
          <view class="goods-item-price">
            <text>
              <text
                :class="item.takeNum == item.stockNum ? 'green' : 'origin'"
                v-if="item.takeNum"
                >{{ item.takeNum ? "库存" + (item.takeNum || 0) : "" }}</text
              >{{ item.takeNum ? "/" : "" }}
              库存:
              {{ item.stockNum ? item.stockNum : 0
              }}{{ item.unit ? "/" + item.unit : "" }}</text
            >

            <!-- <text v-if="item.newsalePrice" class="color-blue"
            >调后价¥{{ item.newsalePrice }}</text
          > -->
          </view>
        </view>
        <view class="scroll-item-right2">
          <image
            v-if="item.takeNum && item.takeNum == item.stockNum"
            src="@/static/images/select2.png"
            mode="scaleToFill" />
          <image
            v-if="item.takeNum && item.takeNum != item.stockNum"
            src="@/static/images/select1.png"
            mode="scaleToFill"
        /></view>
      </view>
    </view>
    <view
      v-if="form.keyword"
      v-for="(item, index) in productDataSearch"
      :key="index"
    >
      <view
        class="scroll-Y-item"
        @click="onClickItem(item, index)"
        v-if="!isShowSock || (isShowSock && item.stockNum > 0)"
      >
        <view class="scroll-item-left">
          <image :src="item.image" mode="scaleToFill" />
        </view>
        <view class="scroll-item-right">
          <view class="goods-item-title">
            {{ item.productName }}
          </view>
          <view class="goods-item-spec">
            条形码: {{ item.barCode ? item.barCode : "--" }}
          </view>
          <view class="goods-item-price">
            <text>
              <text
                :class="item.takeNum == item.stockNum ? 'green' : 'origin'"
                v-if="item.takeNum"
                >{{ item.takeNum ? "库存" + (item.takeNum || 0) : "" }}</text
              >{{ item.takeNum ? "/" : "" }}
              库存:
              {{ item.stockNum ? item.stockNum : 0 }}
              {{ item.unit ? "/" + item.unit : "" }}</text
            >

            <!-- <text v-if="item.newsalePrice" class="color-blue"
            >调后价¥{{ item.newsalePrice }}</text
          > -->
          </view>
        </view>
        <view class="scroll-item-right2">
          <image
            v-if="item.newTakeNum && item.newTakeNum == item.stockNum"
            src="@/static/images/select2.png"
            mode="scaleToFill" />
          <image
            v-if="item.newTakeNum && item.newTakeNum != item.stockNum"
            src="@/static/images/select1.png"
            mode="scaleToFill"
        /></view>
      </view>
    </view>
  </view>
  <!-- v-if="productData.length <= 0 && !loading" -->
  <view class="noData" v-if="productData.length <= 0 && loading == 'noMore'">
    <view class="noData-img">
      <image src="@/static/nodate/datas.png" mode="scaleToFill" />
      <view>暂无商品 </view>
    </view>
  </view>
  <view class="noData" v-if="productDataSearch.length <= 0 && form.keyword">
    <view class="noData-img">
      <image src="@/static/nodate/datas.png" mode="scaleToFill" />
      <view>暂无商品 </view>
    </view>
  </view>

  <view class="loading-form" v-if="loading && productData.length > 0"
    ><van-loading size="24rpx" v-if="loading == 'Loading'"
      ><text class="loading-text">加载中...</text>
    </van-loading>
    <text class="loading-text" v-if="loading == 'More'">加载更多</text>
    <text class="loading-text" v-if="loading == 'noMore'">~没有数据了~</text>
  </view>
  <!-- <view class="loading-form" v-if="form.keyword && productDataSearch.length > 0"
    ><van-loading size="24rpx" v-if="loading == 'Loading'"
      ><text class="loading-text">加载中...</text>
    </van-loading>
    <text class="loading-text" v-if="loading == 'More'">加载更多</text>
    <text class="loading-text" v-if="loading == 'noMore'">~没有数据了~</text>
  </view> -->
  <view style="width: 100%; height: 200rpx"></view>
  <view class="goods_bt">
    <view class="goods_bt_to">
      <view class="goods_bt_left">
        <view @click="showPFun" class="num">
          <text
            >共 <text class="green">{{ newTakeList.length }}</text> 款</text
          >
          <up-icon
            style="margin-left: 10rpx"
            :name="showP ? 'arrow-down' : 'arrow-up'"
            color="#323233"
            size="30rpx"
          ></up-icon
        ></view>
        <text
          class="show"
          :class="isShowSock ? 'showSelect' : ''"
          @click="showSock"
          >有库存商品</text
        >
      </view>

      <van-button class="val-button" type="primary" @click="goRecord"
        >提交盘点</van-button
      >
    </view>
  </view>

  <!-- <view class="mask-k" v-if="show" @click="show = false"></view> -->
  <!--  -->
  <!-- <view
    class="select_price"
    :style="'bottom:' + keyboardHeight + 'px;'"
    :class="!show ? 'select_price_noshow' : ''"
  >
    <view class="select_price_tag" @click="show = false">
      <van-icon name="cross" size="28rpx" color="#86909C" />
    </view>
    <view class="select_price_top">
      <view class="select_price_title">{{ itemObj.name }}</view>
      <view class="select_price_des">{{ itemObj.barCode }}</view>
    </view>
    <view class="select_price_in">
      <view class="select_price_title">新售价 </view>
      <view>
        <van-field
          v-model="priceValue"
          readonly
          clickable
          @touchstart.stop="show = true"
          class="select_price_input"
        >
          <template #button>
            <text>元</text>
          </template>
        </van-field>
      </view>
    </view>
  </view>
  <van-config-provider :theme-vars="themeVars">
    <van-number-keyboard
      :transition="true"
      :hide-on-click-outside="false"
      ref="keyboard"
      class="priceKey"
      v-model="priceValue"
      :show="show"
      theme="custom"
      extra-key="."
      close-button-text="完成"
      @blur="onBlue"
      @input="onInput"
      @delete="onDelete"
      z-index="50"
    />
  </van-config-provider> -->

  <up-popup
    :show="showP"
    :closeOnClickOverlay="true"
    mode="bottom"
    @close="showP = false"
    round="15rpx"
    :closeable="true"
  >
    <view class="sel_p">
      <view class="sel_p-title">盘点列表</view>

      <view>
        <scroll-view scroll-y="true" class="scroll-Y">
          <!-- @click="onClickItem(item, index)" -->
          <view
            class="scroll-Y-item"
            v-for="(item, index) in newTakeList"
            :key="index"
          >
            <view class="scroll-item-left">
              <image :src="item.image" mode="scaleToFill" />
            </view>
            <view class="scroll-item-right">
              <view class="goods-item-title">
                {{ item.productName }}
              </view>
              <view class="goods-item-spec">
                条形码: {{ item.barCode ? item.barCode : "--" }}
              </view>
              <view class="goods-item-price">
                <text>
                  <text v-if="item.stockNum">{{
                    item.stockNum ? "库存" + (item.stockNum || 0) : ""
                  }}</text
                  >{{ item.stockNum ? "/" : "" }}
                  盘点库存:
                  {{ item.takeNum ? item.takeNum : 0
                  }}{{ item.unit ? "/" + item.unit : "" }}</text
                >

                <!-- <text v-if="item.newsalePrice" class="color-blue"
            >调后价¥{{ item.newsalePrice }}</text
          > -->
              </view>
            </view>
            <view class="scroll-item-right2">
              <image
                v-if="item.takeNum && item.takeNum == item.stockNum"
                src="@/static/images/select2.png"
                mode="scaleToFill" />
              <image
                v-if="item.takeNum && item.takeNum != item.stockNum"
                src="@/static/images/select1.png"
                mode="scaleToFill"
            /></view>
          </view>
        </scroll-view>
      </view>
      <view class="goods_bt_to">
        <view class="goods_bt_left" @click="showPFun">
          <text
            >共 <text class="green">{{ newTakeList.length }}</text> 款</text
          >
          <up-icon
            style="margin-left: 10rpx"
            :name="showP ? 'arrow-down' : 'arrow-up'"
            color="#323233"
            size="30rpx"
          ></up-icon>
        </view>
        <van-button class="val-button" type="primary" @click="goRecord"
          >提交盘点</van-button
        >
      </view>
    </view>
  </up-popup>

  <up-popup
    :show="showNOIs"
    :closeOnClickOverlay="false"
    mode="center"
    @close="showNOIs = false"
    round="15rpx"
  >
    <view class="p_content">
      <view class="p_title">此商品不在本次盘点范围内 </view>
      <view class="p_content" v-if="itemObj.barCode"
        >条码：{{ itemObj.barCode }}</view
      >
      <view class="p_content" v-if="itemObj.name"
        >品名：{{ itemObj.name }}</view
      >
      <view class="p_content" v-if="itemObj.categoryName"
        >所属分类：{{ itemObj.categoryName }}</view
      >

      <view
        class="p_btn"
        @click="
          showNOIs = false;
          code = '';
        "
        >确定
      </view>
    </view>
  </up-popup>

  <up-popup
    :show="showNO"
    :closeOnClickOverlay="false"
    mode="center"
    @close="showNO = false"
    round="15rpx"
  >
    <view class="p_content">
      <view class="p_title">该商品未找到</view>

      <view
        class="p_btn"
        @click="
          showNO = false;
          code = '';
        "
        >确定
      </view>
    </view>
  </up-popup>
  <up-popup
    :show="showNOIs"
    :closeOnClickOverlay="false"
    mode="center"
    @close="showNOIs = false"
    round="15rpx"
  >
    <view class="p_content">
      <view class="p_title">此商品不在本次盘点范围内 </view>
      <view class="p_content" v-if="itemObj.barCode"
        >条码：{{ itemObj.barCode }}</view
      >
      <view class="p_content" v-if="itemObj.name"
        >品名：{{ itemObj.name }}</view
      >
      <view class="p_content" v-if="itemObj.categoryName"
        >所属分类：{{ itemObj.categoryName }}</view
      >

      <view
        class="p_btn"
        @click="
          showNOIs = false;
          code = '';
        "
        >确定
      </view>
    </view>
  </up-popup>

  <pomiss ref="pomissview" @cancel="cancelFun" v-model="isshowcamera"></pomiss>

  <noWork @connected="connected"> </noWork>
</template>

<style lang="scss" scoped>
@import "./index.scss";
</style>
